package com.miukoo.aikao.qpaper.choose;


import com.miukoo.aikao.core.choose.JoinTypeInterface;
import com.miukoo.aikao.core.dtos.ExamDto;
import com.miukoo.aikao.core.enums.JoinType;
import com.miukoo.aikao.core.pojos.QuestionChooseDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author miukoo<miukoo@126.com>
 * @Date 2020/11/26  
 * @Version 1.0
 */
@Component
public class JoinTypeInterfaceManager implements JoinTypeInterface {

    @Autowired
    @Qualifier("freeJoinType")
    JoinTypeInterface freeJoinType;

    @Override
    public List<QuestionChooseDto> chooseQuestion(ExamDto dto) {
        return getJoinTypeInterface(dto.getJoinType().shortValue()).chooseQuestion(dto);
    }

    public JoinTypeInterface getJoinTypeInterface(Short joinType){
        if(joinType.equals(JoinType.REPO_JOIN)){
            return freeJoinType;
        }
        if(joinType.equals(JoinType.CUSTOM_JOIN)){
            return freeJoinType;
        }
        return null;
    }

}
